package sjtu.ist.warehouse4ws.dao;

import java.util.List;

import sjtu.ist.warehouse4ws.model.GroupCompany;

public class GroupCompanyDaoHibernate extends BaseDaoHibernate<GroupCompany> implements GroupCompanyDao{
	
	

	public Integer save(GroupCompany groupCompany) {
		
		return (Integer)getHibernateTemplate().save(groupCompany);
	}

	public void update(GroupCompany groupCompany) {
		
		getHibernateTemplate().update(groupCompany);
	}

	public void delete(Integer id) {
		
		getHibernateTemplate().delete(get(id));
	}

	public void delete(GroupCompany groupCompany) {
		
		getHibernateTemplate().delete(groupCompany);
	}

	public List<GroupCompany> findByName(String name) {

		return (List<GroupCompany>)getHibernateTemplate().find("from GroupCompany g where g.name='"+name+"'");
	}

	@Override
	public List<GroupCompany> findByCompany(String companyId) {
		return (List<GroupCompany>)getHibernateTemplate().find("from GroupCompany g where g.companyId='"+companyId+"'");
	}

	@Override
	public List<GroupCompany> findAllGroupCompany() {
		return (List<GroupCompany>)getHibernateTemplate().find("from GroupCompany");
	}

	@Override
	public List<GroupCompany> findUserByCompany(String companyName, int type) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public GroupCompany get(Integer id) {
		// TODO Auto-generated method stub
		return (GroupCompany)getHibernateTemplate().get(GroupCompany.class, id);
	}
}

	